//
// Created by Administrator on
// insert into linkedlist
//


#include <iostream>
#include <vector>
using namespace std;

struct Node{
    int v;
    Node *next;
};

void printLinkedList(Node *h)
{
    Node *cur=h->next;
    while(cur)
    {
        cout<<cur->v<<' ';
        cur=cur->next;
    }
    cout<<endl;
}

// 插入一个节点到head之后
void insert(Node *h,int num)
{
    Node *t=new Node{num,nullptr};
    t->next=h->next;
    h->next=t;
}
int main()
{
    vector<int> l={1,2,3,4,5,6};
    Node *head= new Node();
    Node *cur =head;
    for (int i = 0; i < l.size(); ++i)
    {
        cur->next = new Node{l[i],nullptr};
        cur=cur->next;
    }
    printLinkedList(head);
    insert(head,100);
    printLinkedList(head);

    return 0;
}